home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9933 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.1 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help !!!!! on 'strstr"
  5. Date: 14 Mar 1996 15:46:18 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar14084618@qcd.lanl.gov>
  8. References: <314703FF.4045@msmail.st.stems.com> <jodellDo7097.Bto@netcom.com>
  9.     <TANMOY.96Mar13090926@qcd.lanl.gov> <3147C7AC.6EE3@hsc.unt.edu>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: Steve Fogoros's message of Wed, 13 Mar 1996 23:15:56 -0800
  14.  
  15. In article <3147C7AC.6EE3@hsc.unt.edu>
  16. Steve Fogoros <sfogoros@hsc.unt.edu> writes:
  17.  
  18. SF: Tanmoy Bhattacharya wrote:
  19. SF: 
  20. SF: > Any user function whose name begins with `is' followed by a lower case
  21. SF: > letter violates the ANSI C standard.
  22. SF: 
  23. SF: You mentioned the same kind of violation regarding user functions that start with
  24. SF: 'str' followed by lower case letter in another post. I apologize that I question
  25. SF: this without being intimately familiar with ANSI C Standard. I am having a hard time
  26. SF: believing the standard would consider my use of other than reserved words a violation.
  27.  
  28. Belief depends on experience :-) As a fortran programmer, I had hard
  29. time believing that a language _can_ have reserved words.
  30.  
  31. This is the name space issue: many implementations cannot link code
  32. which defines the same names as in any standard library. The standard
  33. makes a guarantee that the standard library shall not define or use
  34. arbitrary names so that programs which follow the namespace rules in
  35. the standard are portable. Thus, for example, if I name a function
  36. `read', it cannot conflict with a library function name on any ANSI C
  37. implementation where such conflict would cause a problem.
  38.  
  39. Some names are exempt from this guarantee (i.e. they do not belong to
  40. the user name space). These typically start with underscores (the
  41. detailed rules depend on exactly what context they are being used in),
  42. but in addition, for symbols with external linkage, they include the
  43. names of all library routines defined in the standard. Thus, for
  44. example, you cannot name your routine `fprintf'. To allow for
  45. extensions, some names are reserved in exactly the same way as
  46. existing library functions (such as those beginning with `is' and a
  47. lower case letter, or `to' and a lower case letter: presumably to
  48. allow extensions whose names may be similar to the existing functions
  49. declared in <ctype.h>, e.g. `islower' or `toupper'). 
  50.  
  51. By the way, we are only talking of symbols with external
  52. linkage. Unless the appropriate header (<ctype.h> or <string.h> in the
  53. cases under consideration) is included, the use of these names in
  54. other contexts (e.g. static functions or variables, block scope
  55. variables etc.) is perfectly okay.
  56.  
  57. Technically, the use of a name beiginning with `is' and a lower case
  58. letter and with external linkage leads to a violation of a `shall'
  59. condition in the standard, which is outside of any constraint section.
  60.  
  61. SF: (What kind of ticket would I get for an infraction? Is the implementation required to
  62. SF: check for this and warn or error?)
  63.  
  64. It leads to undefined behaviour. So, the compiler is not required to
  65. give a diagnostic: it may however fail to compile your code, compile
  66. it and fail to run it to completion, compile and run it with wrong
  67. results or display a variety of other behviours.
  68.  
  69. SF: 
  70. SF: Seriously, I will look this up because it seems strange to me and I didn't know
  71. SF: anything about it. I quick scanned my K&R2 but did not find anything there.
  72.  
  73. ISO standard: 7.1.3 read in conjunction with 7.13.2. I do not have
  74. K&R2 handy right now, and do not remember if they go into the
  75. namespace issues.
  76.  
  77. Cheers
  78. Tanmoy
  79. --
  80. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  81. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  82. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  83. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  84. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  85. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  86.